import { Component, OnInit } from '@angular/core';
import { MenuItem } from 'primeng/api';
import { ReportService } from './report.service';

@Component({
  templateUrl: './report.component.html',
  styleUrls: ['./report.component.scss'],
  providers: [ReportService]
})
export class ReportComponent implements OnInit {
  items: MenuItem[];
  constructor(
    private reportService: ReportService) { }

  ngOnInit() {
    this.reportService.listReports().subscribe(items => {
      //封装格式为MegaMenu需要的格式
      items.forEach(element => {
        let grpItems = element.items;
        element.items = [];
        let temp = [];
        grpItems.forEach(element => {
          temp.push(element);
        });
        element.items.push(temp);
      });
      this.items = items;
    });
  }

}
